#coding:utf-8
from flask import Flask
from flask import request
import StringIO
import gen_images

app = Flask(__name__)


@app.route('/',methods=["GET"])
def hello_world():
    data = request.args.get('text')
    img = gen_images.gen_img(data)
    buf = StringIO.StringIO()
    img.save(buf,'PNG')

    buf_str = buf.getvalue()
    response = app.make_response(buf_str)
    response.headers['Content-Type'] = 'image/png'
    return response


if __name__ == '__main__':
    app.run(port='7000',)
